package com.benjamin.common;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;

import android.content.Context;

public class WebUtils {

	public static String getString(Context ctx, String strURL)
			throws IOException {
		InputStream inputStream = null;

		try {
			try {
				URL url = new URL(strURL);
				inputStream = url.openStream();

				InputStreamReader inputStreamReader = new InputStreamReader(
						inputStream);

				BufferedReader bufferedReader = new BufferedReader(
						inputStreamReader);
				StringBuilder sb = new StringBuilder();
				String str;

				while ((str = bufferedReader.readLine()) != null) {
					sb.append(str);
				}

				return sb.toString();
			} finally {
				if (inputStream != null) {
					inputStream.close();
				}
			}
		} catch (IOException ioe) {
			android.util.Log.e("WebUtils", ioe.getMessage(), ioe);
			throw ioe;
		}
	}
}
